{include file='header'/}
<body>
<form class="layui-form" action="javascript:;" onsubmit="return dosub(this)">
    <div class="mainBox">
        <div class="main-container layui-container">
            <div class="layui-form-item">
                <label class="layui-form-label required">模型名称</label>
                <div class="layui-input-block">
                    <input type="text" name="name" lay-verify="required|name"
                           autocomplete="off" placeholder="请输入模型名称" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">模型别名</label>
                <div class="layui-input-block">
                    <input type="text" name="alias" lay-verify="required|alias"
                           autocomplete="off" placeholder="请输入模型别名"  class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">类型</label>
                <div class="layui-input-block">
                    <input type="radio" name="type" value="1" title="单页" >
                    <input type="radio" name="type" value="2" title="列表" checked>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">栏目模板</label>
                <div class="layui-input-block">
                    <input type="text" name="index_tpl" lay-verify="required|index_tpl"
                           autocomplete="off" placeholder="请输入栏目模板,不带后缀，如:index_archive"  class="layui-input">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label required">列表模板</label>
                <div class="layui-input-block">
                    <input type="text" name="list_tpl" lay-verify="required|list_tpl"
                           autocomplete="off" placeholder="请输入列表模板,不带后缀，如:list_archive"  class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label required">内容模板</label>
                <div class="layui-input-block">
                    <input type="text" name="show_tpl" lay-verify="required|show_tpl"
                           autocomplete="off" placeholder="请输入内容模板,不带后缀，如:show_archive"  class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">备注说明</label>
                <div class="layui-input-block">
                    <input type="text" name="remark" lay-verify="remark"
                           autocomplete="off" placeholder="请输入备注说明"  class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="1" title="启用" checked>
                    <input type="radio" name="status" value="0" title="禁用">
                </div>
            </div>


        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit=""
                    lay-filter="admin-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>

{include file='footer'/}
<script>
  layui.use(['form', 'jquery'], function () {
    let form = layui.form;

    let $ = layui.jquery;
    form.verify({
      username: ui_rule.username,
      pwd: ui_rule.password,
    });

    window.dosub = function (obj) {
      var loading = layer.load(2);
      $.ajax({
        url: "{:url('models/add')}",
        data: $(obj).serialize(),
        dataType: 'json',
        contentType: 'application/json',
        type: 'post',
        success: function (res) {
          layer.close(loading);
          if (res.code === 200) {
            hui_msg(res.msg, 1, function () {
                var pageId = parent.layer.getFrameIndex (window.name);
                parent.layer.close(pageId);
            });
          } else {
            hui_msg(res.msg, 2);
          }
        }
      })
      return false;
    }
  })
</script>
</body>
</html>
